<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人中心</title>
    <link rel="stylesheet" href="../css/mine.css">
    <link rel="stylesheet" href="../css/publis.css">
    <link rel="stylesheet" href="../font/font_1/iconfont.css">
    <%- include('./header.ejs') -%>
</head>

<body>
    <div class="mine-top">

    </div>
    <div class="nav">
        <ul>
            <a href="#" id="detailPage">
                <li>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-jiankang1"></use>
                    </svg>
                    <p>当前体检</p>
                </li>
            </a>
            <a href="#" class="weeklynewspaper">
                <li>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-jiankang1"></use>
                    </svg>
                    <p>周报</p>
                </li>
            </a>
            <a href="#" id="historyList">
                <li>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-jiankangceping"></use>

                    </svg>
                    <p>历史体检</p>
                </li>
            </a>
        </ul>
    </div>
    <div class="box">

        <table>
            <tr class="binding">

                <td>
                    <div class="left">
                        <svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-zhanghaobangding
                                "></use>
                        </svg>

                        </i>
                        <strong>
                            切换体检人
                        </strong>
                    </div>
                    <div class="right">
                        <i class="iconfont icon-jinrujiantou"></i>
                    </div>
                </td>

            </tr>
            <tr class="user">

                <td>
                    <div class="left">
                        <i class="iconfont icon-gerenshezhi">

                        </i>
                        <strong>
                            个人信息
                        </strong>
                    </div>
                    <div class="right">
                        <i class="iconfont icon-jinrujiantou"></i>
                    </div>
                </td>

            </tr>
        </table>

    </div>
    <%- include('./footer.ejs') -%>

        <script src="../js/jquery-3.6.0.min.js"></script>
        <script src="../font/font_1/iconfont.js"></script>
        <script src="/js/config.js"></script>
        <script src="/js/mine.js"></script>
        <script>
            var REDIRECT_URI = encodeURIComponent(`${URl}/user?Authorization=${Authorization}`);
            var title = localStorage.getItem(('title'));
            $('.user').click(function() {
                window.location.href =
                    `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5bf80eec0759e69c&redirect_uri=${REDIRECT_URI}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
            });
            //周报
            const getLastWeek = (value = null, separate = '-') => {
                // 如果为null,则格式化当前时间
                if (!value) value = Number(new Date());
                // 如果dateTime长度为10或者13，则为秒和毫秒的时间戳，如果超过13位，则为其他的时间格式
                if (value.toString().length == 10) value *= 1000;
                value = +new Date(Number(value));

                const one_day = 86400000; // 24 * 60 * 60 * 1000;
                const lastWeekDate = new Date(value - 7 * one_day);
                const day = lastWeekDate.getDay() === 0 ? 7 : lastWeekDate.getDay(); // 返回1-7,7表示周日
                // 设置时间为上周那天的0点
                lastWeekDate.setHours(0, 0, 0, 0);

                //算出上周开始时间结束时间
                const week_start_time = new Date(lastWeekDate.getTime() - (day - 1) * one_day);
                const week_end_time = new Date(lastWeekDate.getTime() + (7 - day) * one_day);

                //格式化日期
                const filters = n => {
                    return n < 10 ? (n = '0' + n) : n;
                };
                const startmonth = filters(week_start_time.getMonth() + 1);
                const startDay = filters(week_start_time.getDate());
                const endmonth = filters(week_end_time.getMonth() + 1);
                const endDay = filters(week_end_time.getDate());

                const startDateTime = week_start_time.getFullYear() + separate + startmonth + separate + startDay;
                const endDateTime = week_end_time.getFullYear() + separate + endmonth + separate + endDay;

                return {
                    startDateTime: startDateTime,
                    endDateTime: endDateTime,
                };
            };
            var startDateTime = getLastWeek().startDateTime;
            var endDateTime = getLastWeek().endDateTime
            $('.weeklynewspaper').click(function() {
                window.location.href =
                    `weeklynewspaper?BeginTime=${startDateTime}&EndTime=${endDateTime}&IdentityNo=${theRequest.IdentityNo}`
                    // `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appID}&redirect_uri=http%3A%2F%2Fwwrvm5.natappfree.cc%2Fweeklynewspaper?BeginTime=${startDateTime}&EndTime=${endDateTime}&IdentityNo=${theRequest.IdentityNo}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`
            })

            //绑定账号
            $('.binding').click(function() {
                location.href = `bindingList?username=${JSON.parse(title).username}&Authorization=${Authorization}&IdentityNo=${theRequest.IdentityNo}`
            })
        </script>
</body>

</html>